<?php
/** rating project **/
session_start();
//echo 'x';return;
include_once 'libmaster/parse.php';
include_once('libmaster/parseObject.php');
include_once('libmaster/parseQuery.php');
$parseObject = new parseQuery('rate');

//$user->set('objectId','HCqXU6tFoY');

//$parseObject->whereEqualTo('userId',$user);
$projectId= 'TTtyX8ZPiK';
$userId = 'HCqXU6tFoY -54';
$parseObject->whereEqualTo('userId',$userId);
$parseObject->whereEqualTo('projectId',$projectId);
$curl = $parseObject->find();

$a = json_decode($curl);
if(!isset($a->results)){
    die("-1");
}

if(sizeof($a->results)>0){
    die("-1");
}

//chua binh chon: UPdate bang Project, bang Rate
$rate = new parseObject('rate');
$rate->data = array('projectId'=>$projectId,'userId'=>$userId,'id'=>'pwiF8PPfkG');
$rate->save();
//get project
$project = new parseObject('Project');
$data = $project->get($projectId);
echo $data;
//$a = json_decode($project);
if(isset($project->id)){
    echo ('get success');
}
echo $project->get('contributor').' la contributor';
echo '1';
//echo var_dump($a->results);
?>